<template>
<el-container style="border: 1px solid #eee">
        <the-header></the-header>
         <el-container>
           <the-aside></the-aside>
          <router-view></router-view>
        </el-container>
        <el-footer >韬睿科技电子书</el-footer>
</el-container>
</template>

<script>
import TheAside from './components/the-aside.vue'
import TheHeader from './components/the-header.vue'
export default {
  name: 'App',
  components: {
    TheHeader,
    TheAside
  },
   created() {
    //在页面加载时读取sessionStorage里的状态信息
    if (sessionStorage.getItem('store')) {
      this.$store.replaceState(Object.assign({}, this.$store.state, JSON.parse(sessionStorage.getItem('store'))));
    }

    //在页面刷新时将vuex里的信息保存到sessionStorage里
    window.addEventListener('beforeunload', () => {
      sessionStorage.setItem('store', JSON.stringify(this.$store.state));
    });
  }
}
</script>
<style>
  .el-footer{
    background-color: #B3C0D1;
    color: #333;
    line-height: 60px;
    text-align:center;
  }
</style>